﻿using System;

namespace IceCS.DataStructure.Core.LinearList
{
    /// <summary>
    /// 线性表接口
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface ILinarList<T>
    {
        #region 行为

        /// <summary>
        /// 在末尾附加节点
        /// </summary>
        /// <param name="item">节点数据</param>
        void Add(T item);

        /// <summary>
        /// 插入节点
        /// </summary>
        /// <param name="index">插入节点的位置，索引从0开始</param>
        /// <param name="item">节点数据</param>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        void Insert(int index, T item);

        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="item">数据</param>
        void Remove(T item);

        /// <summary>
        /// 删除指定索引的节点
        /// </summary>
        /// <param name="index">节点位置，索引从0开始</param>
        void RemoveAt(int index);

        /// <summary>
        /// 查找节点
        /// </summary>
        /// <param name="index">节点位置，索引从0开始</param>
        /// <returns>表数据</returns>
        T FindIndex(int index);

        /// <summary>
        /// 查找节点
        /// </summary>
        /// <param name="match">判断节点相等的条件</param>
        /// <returns>表数据</returns>
        T Find(Func<T, bool> match);

        /// <summary>
        /// 清空表数据
        /// </summary>
        void Clear();

        #endregion

        #region 属性

        /// <summary>
        /// 判断表是否为空
        /// </summary>
        /// <returns>true为空，false不为空</returns>
        bool IsEmpty { get; }

        /// <summary>
        /// 判断表是否为满
        /// </summary>
        /// <returns>true为满，false不为满</returns>
        bool IsFull { get; }

        /// <summary>
        /// 获取链表元素数量
        /// </summary>
        /// <returns>表长度</returns>
        int Count { get; }

        #endregion
    }
}

